Skip to main content

Execute Function

AutomatR.PostgreSQL.Database.ExecuteFunction

The "Execute Function" activity in AutomatR for PostgreSQL databases allows you to execute a functional statement on a PostgreSQL database. This activity is designed to handle the execution of stored functions with input and output parameters. It provides flexibility in handling both data retrieval and function output parameters.

Properties

NameDescription
Input
ConnectionProvide an NpgsqlConnection variable which will be used to establish a database connection. NpgsqlConnection variables containing the connection to be used.
Function NameSpecify the name of the function to be executed. String variables containing the function name.
Returns TableWhen selected, indicates that the given function is expected to return a table, and data is available in the "Result" property. When not selected, the function may have output variables, and their values are available in the "Out Variables" property. Boolean variables indicating whether the function returns a table.
ParametersDictionary containing input parameters for the function. Each parameter is represented by a key-value pair, where the key is the parameter name, and the value is the argument value.
Command TimeoutProvide the amount of time (in milliseconds) to wait for the SQL command to run before throwing an error.
Misc
Display NameProvides a customizable name for the activity displayed in the workflow. The display name enhances clarity and organization within the automation project. String variables containing the desired display name.
Optional
DelaySpecifies the amount of time (in seconds) to wait before executing the "Execute Function" activity. Integer variables containing the delay duration. Example: If the amount of time is 1000 milliseconds or 1 sec, i.e., 1.
Output
ResultThe result of the SQL command will be stored in a DataTable variable, allowing you to utilize it in subsequent activities or operations. DataTable variables to store the result of the function.
Out VariablesProvides a Dictionary containing output direction parameters and their values after executing the stored function. Dictionary variables to store output parameter values.

How to use:

  1. Drag and drop the "Execute Function" activity onto the workflow.
  2. Configure the properties by specifying the NpgsqlConnection variable obtained from the "Connect" activity, the function name, and input parameters.
  3. Optionally, configure the delay, command timeout, and whether the function returns a table.
  4. Execute the workflow to execute the specified function on the PostgreSQL database.

Example: Consider an example where the "Execute Function" activity is used to execute a function named "sp_add_users" with input parameters and output variables:

Execute Function:
Delay: 2
Connection: myDBConnection
Function Name: "sp_add_users"
Returns Table: False
Parameters:
uid: 3
uname: "QAQA"
Command Timeout: 5000
Result: myFunctionResult
Out Variables: myOutputVariables

In this example, the activity executes the "sp_add_users" function with input parameters "uid" and "uname." If the function has output variables, their values are stored in the Dictionary variable "myOutputVariables," and the result of the SQL command is stored in the DataTable variable "myFunctionResult" for further processing in the workflow.